import {https} from "@/utils/request";
import {PageData} from "@/utils/http";
import {
    RoleCreateFormProp,
    RoleKeyValueProp,
    RoleProp,
    RoleQueryProp,
    UpdateRoleFormProp
} from "@/pages/authority/modules";

// createRole 创建角色
export const createRole = (data: RoleCreateFormProp): Promise<string> => {
    return https.request({
        url: '/authority/role/create',
        method: 'post',
        data: data
    }, {})
}

// createRole 更新角色
export const updateRole = (data: UpdateRoleFormProp): Promise<RoleProp> => {
    return https.request({
        url: '/authority/role/update',
        method: 'post',
        data: data
    }, {})
}

// pageRole 角色分页
export const pageRole = (data: RoleQueryProp): Promise<PageData<RoleProp>> => {
    return https.request({
        url: '/authority/role/page',
        method: 'post',
        data: data
    })
}

// deleteRole 删除角色
export const deleteRole = (ids: string): Promise<boolean> => {
    return https.request({
        url: '/authority/role/delete',
        method: 'get',
        params: {ids: ids}
    })
}

// allRole 所有角色
export const allRole = (): Promise<RoleKeyValueProp[]> => {
    return https.request({
        url: '/authority/role/all',
        method: 'get',
        params: null
    })
}